/**
 * @projectName gs_online
 * @package com.answer.wx.gateway.controller
 * @className com.answer.wx.gateway.controller.CommentController
 */
package com.answer.wx.gateway.controller;

import com.answer.wx.common.aop.ApiOptions;
import com.answer.wx.dao.model.CommentReply;
import com.answer.wx.gateway.service.CommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * CommentController
 * @description 评论controller
 * @author answer_wx
 * @date 2022/8/17 16:31
 * @version 1.0
 */

@RestController
@RequestMapping("/comment")
@Slf4j
@Api(value = "评论接口", tags = {"评论接口"})
public class CommentController {
    @Autowired
    private CommentService commentService;

    @ApiOperation("添加评论")
    @PostMapping("/addComment")
    @ApiOptions
    public void addComment(Integer userId, String userComment, Integer messageId){
        commentService.addComment(userId, userComment, messageId);
    }
    @ApiOperation("删除评论")
    @PostMapping("/deleteCommentByCommentId")
    @ApiOptions
    public void deleteCommentByCommentId(Integer userId,Integer commentId){
        commentService.deleteCommentByCommentId(userId, commentId);
    }

    @ApiOperation("删除评论回复")
    @PostMapping("/deleteCommentReplyById")
    @ApiOptions
    public void deleteCommentReplyById(Integer userId, Integer commentReplyId){
        commentService.deleteCommentReplyById(userId, commentReplyId);
    }

    @ApiOperation("添加评论回复")
    @PostMapping("/addCommentReply/{messageId}")
    @ApiOptions
    public void addCommentReply(@PathVariable Integer messageId,@RequestBody CommentReply commentReply) {
        commentService.addCommentReply(messageId, commentReply);
    }

    @ApiOperation("添加收藏")
    @PostMapping("/addCollection")
    @ApiOptions
    public void addCollection(Integer userId, Integer messageId){
        commentService.addCollection(userId, messageId);
    }

    @ApiOperation("删除收藏")
    @PostMapping("/deleteCollection")
    @ApiOptions
    public void deleteCollection(Integer userId, Integer messageId){
        commentService.deleteCollection(userId, messageId);
    }

    @ApiOperation("查看收藏")
    @GetMapping("/checkIsCollection/{userId}/{messageId}")
    @ApiOptions
    public int checkIsCollection(@PathVariable Integer userId,@PathVariable Integer messageId){
        return commentService.checkIsCollection(userId, messageId);
    }

}